//
//  MenuScene.m
//  iSuDoku
//
//  Created by maccctk on 09-6-23.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "MenuScene.h"
#import "GameScene.h"
#import "RobotScene.h"
#import "LevelScene.h"
#import "HelpScene.h"
#import "AboutScene.h"

@implementation MenuScene

- (id)init {
	self = [super init];
	if(self != nil) {
		Sprite *bg = [Sprite spriteWithFile:@"menu.png"];
		[bg setPosition:ccp(240, 160)];
		[self addChild:bg z:0];
		
		Sprite *logo = [Sprite spriteWithFile:@"logo.png"];
		[logo setPosition:ccp(35, 10)];
		[self addChild:logo z:0];

		[self addChild:[MenuLayer node] z:1];
	}
	return self;
}

@end

@implementation MenuLayer

- (id)init {
	self = [super init];
	if(self != nil) {
		[MenuItemFont setFontSize:24];
		
		MenuItemFont *start = [MenuItemFont itemFromString:@"Start Game" target:self selector:@selector(startGame:)];
		[start.label setRGB:0 :0 :0];

		MenuItemFont *level = [MenuItemFont itemFromString:@"Levels" target:self selector:@selector(level:)];
		[level.label setRGB:0 :0 :0];
		
		MenuItemFont *robot = [MenuItemFont itemFromString:@"Make Game" target:self selector:@selector(robot:)];
		[robot.label setRGB:0 :0 :0];
		
		MenuItemFont *help = [MenuItemFont itemFromString:@"Help" target:self selector:@selector(help:)];
		[help.label setRGB:0 :0 :0];
		
		MenuItemFont *about = [MenuItemFont itemFromString:@"About" target:self selector:@selector(about:)];
		[about.label setRGB:0 :0 :0];
		
		Menu *menu = [Menu menuWithItems:start, level, robot, help, about, nil];
		
		[menu alignItemsVertically];
		[self addChild:menu];
	}
	return self;
}

- (void)startGame:(id)sender {
	GameScene *gs = [GameScene node];
	[[Director sharedDirector] replaceScene:gs];
	NSLog(@"start game");
}

- (void)level:(id)sender {
	LevelScene *ls = [LevelScene node];
	[[Director sharedDirector] replaceScene:ls];
	NSLog(@"level");
}

- (void)robot:(id)sender {
	RobotScene *rs = [RobotScene node];
	[[Director sharedDirector] replaceScene:rs];
	NSLog(@"robot");
}

- (void)help:(id)sender {
	HelpScene *hs = [HelpScene node];
	[[Director sharedDirector] replaceScene:hs];
	NSLog(@"help");
}

- (void)about:(id)sender {
	AboutScene *as = [AboutScene node];
	[[Director sharedDirector] replaceScene:as];
	NSLog(@"about");
}

@end
